package leetcode.code1785;

import java.util.Iterator;

import leetcode.IDebug;
import leetcode.helper.H;

public class Solution implements IDebug {

	public int minElements(int[] nums, int limit, int goal) {
		long sum = 0;
		for (int i = 0; i < nums.length; i++) {
			sum += nums[i];
		}
		long diff = Math.abs(goal - sum);
		return (int) (diff + limit - 1) / limit;
	}

	@Override
	public void debug4() {
		H.compare(1, this.minElements(H.str2array3("[1,-10,9,1]"), 100, 0));
		H.compare(2, this.minElements(H.str2array3("[1,-1,1]"), 3, -4));
		H.compare(2, this.minElements(H.str2array3("[1,-1,1]"), 3, -4));

	}

	@Override
	public void debug3() {
		// TODO Auto-generated method stub

	}

	@Override
	public void debug2() {
		// TODO Auto-generated method stub

	}

	@Override
	public void debug1() {
		// TODO Auto-generated method stub

	}

	public static void main(String[] args) {
		Solution so = new Solution();
		so.debug1();
		so.debug2();
		so.debug3();
		so.debug4();

	}

}
